<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>属性选择器</title>
    <style>
        /*具有title或者title2的上色*/
        [title] {
            color: red;
        }
        [title="2"] {
            color: yellow;
        }
        [title2] {
            color: blue;
        }
        /*title2以2a开头*/
        [title2^="2a"] {
            color: chocolate;
        }
        /*title2以ba结尾*/
        [title2$="ba"] {
            color: chocolate;
        }
        /*title2包含了y*/
        [title2*="y"] {
            color: green;
        }
    </style>
</head>
<body>
<div title="1">1</div>
<div title="2">2</div>
<div title2="1bbbbbba">3</div>
<div title2="2aaaa">4</div>
<div title2="mmmjjhhys">4</div>
</body>
</html>